﻿using TrainGame.Model;

namespace TrainGame.AI
{
	/// <summary>
	/// Configuration information for AI.
	/// </summary>
	public class AiMoveConfig
	{
		public Game Game { get; private set; }
		public PublicCompany Company { get; private set; }
		public Player Player { get; private set; }

		public bool AllowYellowTile { get; private set; }
		public bool AllowGreenTile { get; private set; }
		public bool AllowBrownTile { get; private set; }
		public bool AllowGrayTile { get; private set; }

		/// <summary>
		/// Initialize the AI move config based on current Game state and specified Player
		/// </summary>
		/// <remarks>
		/// Note we take Player not AiPlayer in case we eventually want to support move hints for non-AI players
		/// </remarks>
		/// <param name="game">current game</param>
		/// <param name="company">the operating company (or null)</param>
		/// <param name="player">desired player</param>
		public AiMoveConfig(Game game, PublicCompany company, Player player)
		{
			Game = game;
			Company = company;
			Player = player;

			AllowYellowTile = game.YellowTilesAvailable;
			AllowGreenTile = game.GreenTilesAvailable;
			AllowBrownTile = game.BrownTilesAvailable;
			AllowGrayTile = game.GrayTilesAvailable;
		}

		public bool AllowTile(Tile tile)
		{
			switch (tile.Color)
			{
				case Tile.eTileColor.Yellow:
					return AllowYellowTile;

				case Tile.eTileColor.Green:
					return AllowGreenTile;

				case Tile.eTileColor.Brown:
					return AllowBrownTile;

				case Tile.eTileColor.Gray:
					return AllowGrayTile;

				default:
					return false;
			}
		}
	}
}
